/*
 ============================================================================
 Name		: RSSBriefData.cpp
 Author	  : JohnLZeng
 Version	 : 1.0
 Copyright   : Your copyright notice
 Description : CRSSBriefData implementation
 ============================================================================
 */

#include "RSSBriefData.h"
#include "MacroUtil.h"

CRSSBriefData::CRSSBriefData()
:iTitle(NULL),iUpdate(ETrue),
iReadState(EDocListUnread),iFileState(EDocListFileNull)
	{
	// No implementation required
	}

CRSSBriefData::~CRSSBriefData()
	{
	SAFE_DELETE(iTitle)
	SAFE_DELETE(iMp3Url)
	SAFE_DELETE(iMp3File)
	}

CRSSBriefData* CRSSBriefData::NewLC()
	{
	CRSSBriefData* self = new (ELeave) CRSSBriefData();
	CleanupStack::PushL(self);
	self->ConstructL();
	return self;
	}

CRSSBriefData* CRSSBriefData::NewL()
	{
	CRSSBriefData* self = CRSSBriefData::NewLC();
	CleanupStack::Pop(); // self;
	return self;
	}

void CRSSBriefData::ConstructL()
	{

	}

void CRSSBriefData::SetTitle(const TDesC& aTitle)
	{
	SAFE_DELETE(iTitle)
	
	iTitle = aTitle.AllocL();
	}

void CRSSBriefData::AppendTitle(const TDesC& aTitle)
	{
	if (iTitle)
		{
		iTitle = iTitle->ReAllocL(iTitle->Length() + aTitle.Length());
		iTitle->Des().Append(aTitle);
		}
	else
		iTitle = aTitle.AllocL();
	}

CQWString CRSSBriefData::GetTitleQ()
	{
	CQWString title;
	if (iTitle)
		{
		TPtrC ptr = iTitle->Des();
		title.SetData((LPCWSTR)(ptr.Ptr()),ptr.Length());
		}
	return title;
	}

void CRSSBriefData::SetMp3File(const TDesC& aFile)
	{
	SAFE_DELETE(iMp3File)
	
	iMp3File = aFile.AllocL();
	}
void CRSSBriefData::SetMp3Url(const TDesC& aUrl)
	{
	SAFE_DELETE(iMp3Url)
	
	iMp3Url = aUrl.AllocL();
	}

void CRSSBriefData::SetMp3(const TDesC& aMp3Url)
	{
	SAFE_DELETE(iMp3Url)
	SAFE_DELETE(iMp3File)
	
	iMp3Url = aMp3Url.AllocL();
	
	TInt pos = aMp3Url.LocateReverse('/');
	iMp3File = aMp3Url.Mid(pos+1).AllocL();
	}
